import { create } from "zustand";

const useStore = create<BearType>()((set, get) => {
  return {
    bears: 0,
    incrementBears: () => set((state) => ({ bears: state.bears + 1 })),
    resetBears: () => set({ bears: 0 }),
    decrementBearsByStep: (step = 1) => set((state) => ({ bears: (state.bears -= step) })),
    asyncIncrementBears: async () => {
      await new Promise((resolve) => setTimeout(resolve, 1000));
      // set((state) => ({ bears: state.bears + 1 }));
      get().incrementBears()
    },
    fishes: 0,
    incrementFishes: () => set((state) => ({ fishes: state.fishes + 1 })),
    resetFishes: () => set({ fishes: 0 }),
  };
});

export default useStore;
